<template>
	<view style="padding: 40rpx;">
		<up-input v-model="name" shape="circle"></up-input>

		<view class="" style="padding: 40rpx;">
			<up-button type="error" shape="circle" text="提交" @click="save"></up-button>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import mineApi from '../../../api/mine';
	const app = JSON.parse(uni.getStorageSync("app"));
	const name = ref(app.nickName);

	const save = async () => {
		const res = await mineApi.updateUser({
			app: 4,
			m: app.account,
			n: name.value
		});
		console.log(res);
		if (res.msg === "成功") {
			app.nickName = name.value;
			uni.showToast({
				icon: 'none',
				title: "修改成功"
			});
			uni.setStorageSync("app", JSON.stringify(app));
			setTimeout(() => {
				uni.navigateBack()
			}, 600)
		}
	}
</script>

<style>

</style>